var e = require;
var t = module;
var o = exports;
var n,
    i = o,
    a =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        }),
    r = function (e, t, o, n) {
        var i,
            a = arguments.length,
            r = a < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n);
        else
            for (var s = e.length - 1; s >= 0; s--)
                (i = e[s]) && (r = (a < 3 ? i(r) : a > 3 ? i(t, o, r) : i(t, o)) || r);
        return a > 3 && r && Object.defineProperty(t, o, r), r;
    };
Object.defineProperty(i, "__esModule", {value: !0});
var s = e("SkinLevelData"),
    c = cc._decorator,
    l = c.ccclass,
    d =
        (c.property,
        (function (e) {
            function t() {
                var t = (null !== e && e.apply(this, arguments)) || this;
                return (
                    (t.themes = []),
                    (t.currentIndex = 0),
                    (t.beforeWidth = 216),
                    (t.beforeHeight = 144),
                    (t.afterWidth = 270),
                    (t.afterHeight = 180),
                    (t.isAnimal = !1),
                    (t.isInit = !1),
                    (t.callBackFunc = null),
                    t
                );
            }
            return (
                a(t, e),
                (t.prototype.init = function (e) {
                    void 0 === e && (e = 0), (this.isAnimal = !1), (this.currentIndex = e);
                    for (var t = 0; t < 4; t++)
                        (this.themes[t] = this.node.getChildByName("theme" + (t + 1))),
                            e === t
                                ? ((this.themes[t].width = this.afterWidth), (this.themes[t].height = this.afterHeight))
                                : ((this.themes[t].width = this.beforeWidth),
                                  (this.themes[t].height = this.beforeHeight));
                    this.addEvent();
                }),
                (t.prototype.registerSkipEvent = function (e, t) {
                    e && (this.callBackFunc = e.bind(t));
                }),
                (t.prototype.addEvent = function () {
                    var e = this;
                    if (!this.isInit) {
                        this.isInit = !0;
                        for (
                            var t = function (t) {
                                    o.themes[t].on(
                                        cc.Node.EventType.TOUCH_START,
                                        function () {
                                            return e.skipIndex(t);
                                        },
                                        o
                                    );
                                },
                                o = this,
                                n = 0;
                            n < this.themes.length;
                            n++
                        )
                            t(n);
                    }
                }),
                (t.prototype.skipIndex = function (e) {
                    var t = this;
                    if ((game.AudioManager.playBtnEffect(), this.isAnimal || this.currentIndex === e)) return !1;
                    (this.isAnimal = !0),
                        this.callBackFunc(e),
                        cc.tween(this.themes[e]).to(0.2, {width: this.afterWidth, height: this.afterHeight}).start(),
                        cc
                            .tween(this.themes[e].getChildByName("font"))
                            .parallel(cc.tween().by(0.2, {y: -10.6}), cc.tween().to(0.2, {scale: 1.2}))
                            .start(),
                        cc
                            .tween(this.themes[this.currentIndex])
                            .to(0.2, {width: this.beforeWidth, height: this.beforeHeight})
                            .start(),
                        cc
                            .tween(this.themes[this.currentIndex].getChildByName("font"))
                            .parallel(cc.tween().by(0.2, {y: 10.6}), cc.tween().to(0.2, {scale: 1}))
                            .start(),
                        this.scheduleOnce(function () {
                            (t.currentIndex = e), (t.isAnimal = !1);
                        }, 0.3);
                }),
                (t.prototype.renderItem = function () {
                    for (var e = 0; e < this.themes.length; e++) {
                        var t = s.SkinLevelData.instance.getSkinLevelByTheme(e + 1),
                            o = t.filter(function (e) {
                                return e.isLock;
                            }).length;
                        this.themes[e].getChildByName("font").getChildByName("num").getComponent(cc.Label).string =
                            o + "/" + t.length;
                    }
                }),
                r([l], t)
            );
        })(cc.Component));
i.default = d;
